﻿using Autofac;
using PLC.Domain.ScheduledTasks.Job;
using PLC.Domain.ScheduledTasks.Strategy.Read;
using PLC.Domain.ScheduledTasks.Strategy.Trigger;
using PLC.Domain.ScheduledTasks.Strategy.Write;

namespace PLC.Domain.ScheduledTasks;

public class AutofacScheduledModule:Module
{
    protected override void Load(ContainerBuilder builder)
    {
        builder.RegisterType(typeof(PLCReadAndWriteJob))
            .As(typeof(IPLCReadAndWriteJob))
            .InstancePerLifetimeScope()
            .PropertiesAutowired();

        builder.RegisterTypes(typeof(ReadCodeData),
                typeof(ReadProductionData),
                typeof(ReadStatusData),
                typeof(ReadConnectionStatus),
                typeof(ReadProcessData))
            .As<BaseRead>()
            .InstancePerLifetimeScope()
            .PropertiesAutowired();

        builder.RegisterTypes(typeof(BipolarPlateCodeStrategy), typeof(NoActionStrategy),
            typeof(ValidateMembraneElectrodeCodeStrategy),
            typeof(BipolarPlateCodeStrategy),typeof(ValidateLowerEndPlateCodeStrategy),typeof(ValidateUpperEndPlateCodeStrategy)
            ,typeof(HandleStatusDataStrategy),typeof(KeepConnectionStrategy))
            .As<BaseTrigger>()
            .InstancePerLifetimeScope()
            .PropertiesAutowired();

        builder.RegisterTypes(typeof(WriteResultStrategy),typeof(WriteConnectionTestStrategy))
            .As<BaseWrite>()
            .InstancePerLifetimeScope()
            .PropertiesAutowired();
    }
}